package com.usabb.service.impl;

import com.usabb.api.dto.*;
import com.usabb.domain.MaternityBaseDO;
import com.usabb.enums.BizTypeEnum;
import com.usabb.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class CenterApiServiceImpl implements CenterApiService {

    @Autowired
    private MaternityBaseService maternityBaseService;
    @Autowired
    private AttachService attachService;
    @Autowired
    private RoundRelationService roundRelationService;
    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private AmenityService amenityService;
    @Autowired
    private GuestCaseService guestCaseService;

    @Override
    public MaternityBaseDO getFullDOById(Long id) {
        MaternityBaseDO maternityBaseDO = maternityBaseService.selectById(id);
        appendDetail(maternityBaseDO);

        return maternityBaseDO;
    }

    @Override
    public void appendDetail(MaternityBaseDO baseDO) {
        final Long id = baseDO.getId();
        //组装民宿周边信息
        List<RoundTypeDTO> roundTypeDTOS = roundRelationService.getRoundTypeDTOListBy(BizTypeEnum.CENTER, id);
        baseDO.setRoundTypes(roundTypeDTOS);

        //组装民宿图片
        AttachesDTO attachesDTO = attachService.getAttachesDTOBy(BizTypeEnum.CENTER, id);
        baseDO.setAttaches(attachesDTO);

        //组装关联医院
        final List<HospitalDTO> hospitalDTOS = hospitalService.getDTOListByBizTypeAndBizId(BizTypeEnum.CENTER, id);
        baseDO.setHospitals(hospitalDTOS);

        //组装配套设施
        AmenitiesDTO amenitiesDTO = amenityService.getByBizTypeAndBizId(BizTypeEnum.CENTER, id);
        baseDO.setAmenities(amenitiesDTO);

        //组装客户感言
        final List<GuestCaseDTO> guestCaseDTOS = guestCaseService.getBy(BizTypeEnum.CENTER, id);
        baseDO.setGuestCases(guestCaseDTOS);
    }
}
